 #include<stdio.h>
  #include<unistd.h>
  #include<fcntl.h>
  #include<stdlib.h>
  #include<errno.h>
  #include<string.h>
  #include<sys/stat.h>
  #define FILE(NUM) "file"#NUM 
  int main(){
	  printf("stdin:%d\n",stdin->_fileno); 
	  printf("stdout:%d\n",stdout->_fileno); 
	  printf("stderr:%d\n",stderr->_fileno); 
      umask(0); //cancel system umask 
      //"w" = O_WRONLY(write file) + O_CREAT(create file) +  O_TRUNC (clean file)
      //"a" = O_WRONLY(write file) + O_CREAT(create file) +  O_APPEND (append file)
      //"r" = O_RDONLY(read file) 
      int fd1 = open(FILE(1),O_WRONLY | O_CREAT | O_TRUNC ,0666);
      int fd2 = open(FILE(2),O_WRONLY | O_CREAT | O_TRUNC ,0666);
      int fd3 = open(FILE(3),O_WRONLY | O_CREAT | O_TRUNC ,0666);
      int fd4 = open(FILE(4),O_WRONLY | O_CREAT | O_TRUNC ,0666);
	  printf("fd1:%d\n",fd1);
	  printf("fd2:%d\n",fd2);
	  printf("fd2:%d\n",fd3);
	  printf("fd4:%d\n",fd4);
      close(fd1);
      close(fd2);
      close(fd3);
      close(fd4);
      return 0;
  }

